using System;
using System.Collections.Generic;
using UnityEngine;

public class MoodConfig : ScriptableObject
{
	[Serializable]
	public class MoodStage
	{
		public string spriteName;

		public float minMood;

		public float maxMood;

		public bool IsStageActive(float mood)
		{
			return mood >= minMood && mood < maxMood;
		}

		public bool IsLowerStage(MoodStage other)
		{
			return other == null || minMood < other.minMood;
		}

		public bool IsHigherStage(MoodStage other)
		{
			return other == null || maxMood > other.maxMood;
		}
	}

	private static MoodConfig instance_;

	public List<MoodStage> stages = new List<MoodStage>();

	public static MoodConfig instance
	{
		get
		{
			if (instance_ == null)
			{
				instance_ = Resources.Load("MoodConfig", typeof(MoodConfig)) as MoodConfig;
			}
			return instance_;
		}
	}

	public string GetSpriteForMood(float mood)
	{
		MoodStage moodStage = null;
		MoodStage moodStage2 = null;
		foreach (MoodStage stage in stages)
		{
			if (stage.IsStageActive(mood))
			{
				return stage.spriteName;
			}
			if (stage.IsLowerStage(moodStage))
			{
				moodStage = stage;
			}
			if (stage.IsHigherStage(moodStage2))
			{
				moodStage2 = stage;
			}
		}
		if (mood <= moodStage.minMood)
		{
			return moodStage.spriteName;
		}
		if (mood >= moodStage2.maxMood)
		{
			return moodStage2.spriteName;
		}
		return string.Empty;
	}
}
